//
//  ReviewTableViewCell.m
//  Mtime2.0
//
//  Created by 凉气的Mac on 16/9/21.
//  Copyright © 2016年 凉气的Mac. All rights reserved.
//

#import "ReviewTableViewCell.h"

@interface ReviewTableViewCell ()

@property(nonatomic,weak) UIImageView *picture;

@property(nonatomic,weak) UILabel *titleLabel;

@property(nonatomic,weak) UILabel *MyTextLabel;

//用户头像
@property(nonatomic,weak) UIImageView *userIcon;

//用户昵称
@property(nonatomic,weak) UILabel *userName;

//电影名字
@property(nonatomic,weak) UILabel *moveName;

//评分
@property(nonatomic,weak) UILabel *markLabel;
@end

@implementation ReviewTableViewCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{

    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setupUI ];
        
    }
    
    return self;
}

-(void)setupUI{

    
    UILabel *titleLabel = [[UILabel alloc]init];
    
    titleLabel.text = @"爱上大家安静的骄傲是极好的归结为";
    
    self.titleLabel = titleLabel;
    
    [self.contentView addSubview:titleLabel];
    
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.left.equalTo(self.contentView).offset(15);
        
    }];
    
    UIImageView *picture = [[UIImageView alloc]init];
    
    self.picture = picture;
    
    [self.contentView addSubview:picture];
    
    picture.image = [UIImage imageNamed:@"icon_default_200x310"];
    
    [picture mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(titleLabel.mas_bottom);
        
        make.right.equalTo(self.contentView).offset(-15);
        
        make.width.equalTo(@45);
        
        make.height.equalTo(@60);
        
        make.bottom.equalTo(self.contentView).offset(-15);
        
    }];
    
    UILabel *textLabel = [self addLabelWithTop:titleLabel];
    
    self.MyTextLabel = textLabel;
    
    textLabel.numberOfLines = 2;
    
    [textLabel mas_updateConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(titleLabel);
        
        make.right.equalTo(picture.mas_left).offset(-15);
        
    }];
    
    
    UIImageView *userIcon = [[UIImageView alloc]init];
    
    self.userIcon = userIcon;
    
    userIcon.image = [UIImage imageNamed:@"icon_default_130x130"];
    
    userIcon.layer.cornerRadius = 12.5;
    
    userIcon.clipsToBounds = YES;
    
    [self.contentView addSubview:userIcon];
    
    [userIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(textLabel.mas_bottom).offset(3);
        
        make.left.equalTo(textLabel);
        
        make.width.height.equalTo(@25);
        
    }];
    
    
    UILabel *userName = [self addLabelWithTop:textLabel];
    
    self.userName = userName;
    
    userName.text = @"光头与凉气";
    
    [userName mas_updateConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(userIcon.mas_right).offset(5);
        
    }];
    
    
    UILabel*moveName = [self addLabelWithTop:textLabel];
    
    self.moveName = moveName;
    
    moveName.text = @"<<噗噗噗噗>>";
    
    [moveName mas_updateConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(userName.mas_right).offset(5);
        
    }];
    
    UILabel *markLabel = [self addLabelWithTop:textLabel];
    
    self.markLabel = markLabel;
    
    markLabel.backgroundColor = [UIColor greenColor];
    
    markLabel.text = @"10.0";
    
    [markLabel mas_updateConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(moveName.mas_right).offset(5);
        
    }];
    
    
}

-(UILabel *)addLabelWithTop:(UIView *)topView{

    UILabel *label = [[UILabel alloc]init];
    
    label.text = @"案件是大家哈就回到家后孤岛惊魂为国际化和房间号广东省交换机和大家好";
    
    label.font = [UIFont systemFontOfSize:12];
    
    label.textColor = [UIColor lightGrayColor];
    
    [self.contentView addSubview:label];
    
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(topView.mas_bottom).offset(8);
        
    }];
    
    return label;

}

@end











































